from flask_marshmallow import base_fields
from flask_restplus_patched import ModelSchema
from app.modules.common.schemas import BaseSchema

class AgentBaseSchema(BaseSchema):
    class Meta:
        fields = (
            "id",
            "ip",
            "load_level",
            "machine_ip",
            "level_name",
            'record_id',
            'create_date',
            'plan_id',
            'plan_name',
            'applicant_id',
            'applicant_name',
            'start_date',
            'expect_recover_date',
            'desc',
            'status',
            'agent_ip',
            'agent_status',
            'added_desc',
            'audit_id',
            'audit_name',
            'apply_load_level_name',
            'type',
            'isUseWeb',
            'useWebDesc',
            'isIntegration',
            'useOldEnv',
            'isKeep',
            'vm_id',
            'is_del',
        )

        dump_only = (
            "id",
        )


class AgentListSchema(BaseSchema):
    data = base_fields.Nested(
        AgentBaseSchema,
        many = True
    )

    class Meta:
        fields = BaseSchema.Meta.fields + (
            'data',
        )


class ZoneBaseSchema(ModelSchema):
    class Meta:
        fields = (
            'zone_code',
            'zone_title',
            'parent_code',
        )


class ZoneListSchema(BaseSchema):
    data = base_fields.Nested(
        ZoneBaseSchema,
        many = True
    )

    class Meta:
        fields = BaseSchema.Meta.fields + (
            'data',
        )
